import {
  END_ANIMATION,
  END_RECORD,
  ENDED_VIDEO,
  HIDDEN_MODAL,
  HIDE_LOADING,
  HIDE_POST,
  PLAY_NEXT,
  PLAY_VIDEO,
  RESET_CURRENT,
  SAVE_RECORD,
  SAVE_VIDEO_CONTEXT,
  SET_CURRENT_PLAY_STATE,
  SET_VOICE_PATH,
  SHOW_LOADING,
  SHOW_MODAL,
  SHOW_NEXT_BEANS,
  SHOW_POST,
  START_ANIMATION,
  START_RECORD,
  UPDATE_CURRENT_TIME
} from "../../mutation-types";

export default {
  [SHOW_LOADING](state, data) {
    state.isLoading = data;
  },

  [HIDE_LOADING](state, data) {
    state.isLoading = data;
  },

  [SHOW_MODAL](state) {
    state.modalShow = true;
  },

  [HIDDEN_MODAL](state) {
    state.modalShow = false;
  },

  [START_ANIMATION](state, { animation, animationShow, isAnimationEnd }) {
    state.isAnimationEnd = isAnimationEnd;
    state.animation = animation;
    state.animationShow = animationShow;
  },
  [END_ANIMATION](state, { animation, animationShow, isAnimationEnd }) {
    state.isAnimationEnd = isAnimationEnd;
    state.animation = animation;
    state.animationShow = animationShow;
  },

  [SET_VOICE_PATH](state, voicePath) {
    state.currentVoicePath = voicePath;
  },

  [SET_CURRENT_PLAY_STATE](state, { currentPlayState, currentRecordIsFinish }) {
    state.currentPlayState = currentPlayState;
    state.currentRecordIsFinish = currentRecordIsFinish;
  },

  [START_RECORD](state) {
    state.isRecording = true;
  },

  [END_RECORD](state) {
    state.isRecording = false;
    state.currentRecordIsFinish = true;
  },

  [SAVE_RECORD](state, { recordPath = "", upload_audio = "" }) {
    state.recordPath = recordPath;
    state.upload_audio = upload_audio;
    state.currentRecordIsFinish = true;
  },

  [SAVE_VIDEO_CONTEXT](state, { videoContext }) {
    state.videoContext = videoContext;
  },

  [PLAY_VIDEO](state) {
    state.isEnded = false;
    state.isPlay = true;
  },

  [ENDED_VIDEO](state) {
    state.isPlay = false;
    state.isEnded = true;
  },

  [UPDATE_CURRENT_TIME](state, currentTime) {
    state.currentTime = currentTime;
  },

  [PLAY_NEXT](state, { current }) {
    state.current = current;
  },
  [SHOW_NEXT_BEANS](state, { current_beans }) {
    state.bean_current = current_beans;
  },

  [RESET_CURRENT](state) {
    console.log("重置当前序列");
    state.current = 0;
    state.bean_current = 0;
  },

  [SHOW_POST](state){
    state.postShow = true
  },

  [HIDE_POST](state){
    state.postShow = false
  }
};
